<script setup lang='ts'>
import { onMounted, ref, defineExpose, defineProps } from 'vue';
import { getUserMessage } from '../../api/message';
import { useRouter } from 'vue-router';
import { getUserMessageList } from '../../api/message'
const router = useRouter()
const dialogVisible = ref(false)
const medetail = ref({})
const id = ref()
onMounted(() => {
  bulletininfo()
})
const bulletininfo = async () => {
  let res = await getUserMessageList({ page: 1, count: 5, message_type: "官方公告" });
  if (res.data.code == 200) {
    if (res.data.data[0]) {
      id.value = res.data.data[0].message_id
      getuser()
    }
  }
}
const getuser = async () => {
  let res = await getUserMessage(id.value);
  console.log(res);
  if (res.data.code == 200) {
    medetail.value = res.data.data;
  }
}
defineExpose({
  someMethod() {
    dialogVisible.value = true
  }
})
const dialo = (a) => {
  dialogVisible.value = false
  router.push(`/news/messagedetail?message_id=${id.value}`)
}
</script>

<template>
  <div>
    <el-dialog v-model="dialogVisible" :title=medetail.title width="500" align-center>
      <div v-html="medetail.content"></div>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="dialo(medetail.message_id)">
            查看更多
          </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<style lang='scss' scoped></style>
